/*
 * @Author: your name
 * @Date: 2021-11-22 16:02:33
 * @LastEditTime: 2022-01-14 18:15:50
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \agricultural-production-web\src\api\basic-info-manage\agr-source-base-Manage\index.js
 */
/*
 * @Description: 农资管理，不是农资类别管理
 */
import request from '@/utils/request'

export default {
  getAllBasicList(params) {
    return request.post("/v3/template/material/queryPageByCondition", {
      page: params.page,
      size: params.size,
      auditFlag: 1,
      entity: {
        ...params.entity || {},
        organizationNo: sessionStorage.organizationNo,
        farming: sessionStorage.farming
      }
    })
  },
  getAllBList(params) {
    return request.post("/v3/template/material/queryByCondition", {
      ...params,
      auditFlag: 1,
      "organizationNo": sessionStorage.organizationNo
    })
  },
  getFarmingAssetList(params) {
    return request.post("/v3/templateTenant/material/queryPageByCondition", {
      ...params,
      auditFlag: 1,
      entity: {
        organizationNo: sessionStorage.organizationNo,
        // farming: sessionStorage.farming
      }
    });
  },
  getFarmingAssetLists(params) {
    return request.post("/v3/templateTenant/materialType/queryTree");
  },

  /**
   * @description: 获取所有农资表格列表 *代表必填
   * @param {String/Number} page *
   * @param {String/Number} size *
   */
  getUnitList(params) {
    return request.post("om/agriculturalMaterial/queryPageList", {
      auditFlag: 1,
      ...params
      // entity: {
      //   // farmingTypeNo: sessionStorage.farmingTypeNo
      // }
    });
  },
  /**
   * @description:模糊查询农资表格列表 *代表必填
   */
  getqueryList(params) {
    return request.post("/v3/templateTenant/material/queryByCondition", {
      // auditFlag: 1,
      // farmingTypeNo: sessionStorage.farmingTypeNo,
      // agriculturalMaterialName: params
      ...params,
      organizationNo: sessionStorage.organizationNo
    });
  },
  /**
   * @description: 添加农资数据
   * @param {Object}  *
   */
  addList(params) {
    return request.post('/v3/templateTenant/material/importPublicList', {
      list: params,
      organizationNo: sessionStorage.organizationNo
    });
  },
  /**
   * @description: 批量删除农资数据
   * @param {Object}  *
   */
  delList(params) {
    return request.post('/v3/templateTenant/material/delListByNo', {
      list: params,
      organizationNo: sessionStorage.organizationNo
    });
  },
  addListES(params) {
    return request.post('/v3/template/applyMaterial/add', {
      ...params,
      organizationNo: sessionStorage.organizationNo
    });
  },
  editListES(params) {
    return request.post('/v3/template/applyMaterial/edit', {
      ...params,
      organizationNo: sessionStorage.organizationNo
    });
  },
  getListES(params) {
    return request.post('/v3/template/applyMaterial/queryByCondition', {
      ...params,
      organizationNo: sessionStorage.organizationNo
    });
  }
};
